﻿<?php $this->load->view('common/admin_header');?>
<div class="block">
  <div class="block_head">
    <div class="bheadl"></div>
    <div class="bheadr"></div>
    <h2><?=$lang['orders_lable_1']?></h2>
    <ul>
      <li><a href="javascript:void(0);" onClick="promotion_url('<?=site_url('admins/promotion/order')?>');" ><i class="icon-gift"></i><?=$lang['orders_lable_3']?></a></li>
    </ul>
  </div>
  <!-- .block_head ends -->
  <div class="block_content">
    <p class="breadcrumb"><?=$lang['global_lable_14']?> &raquo; <a href="<?=site_url('admins/index')?>"><?=$lang['global_lable_11']?></a> &raquo; <?=$lang['orders_lable_1']?> &raquo; <strong><?=$lang['orders_lable_1']?></strong></p>
    <?php $this->load->view('common/notify');?>
    <form action="<?=site_url('admins/orders')?>" method="get">
      <input type="hidden" name="field" value="<?=isset($field)?$field:'add_time'?>" id="field">
      <input type="hidden" name="sort" value="<?=isset($sort)?$sort:'desc'?>" id="sort">
      <table cellpadding="0" cellspacing="0" width="100%" class="sortable">
        <thead>
          <tr>
            <th><input type="checkbox" name="chk_all" id="chk_all"></th>
            <th><a id="invoice_no" class="<?=isset($field) && $field=='invoice_no'?$sort:'';?>" href="#"><?=$lang['orders_lable_6']?></a></th>
            <th><a id="nickname" class="<?=isset($field) && $field=='nickname'?$sort:'';?>" href="#"><?=$lang['orders_lable_7']?></a></th>
            <th><a id="phone" class="<?=isset($field) && $field=='phone'?$sort:'';?>" href="#"><?=$lang['orders_lable_8']?></a></th>
            <th><a id="total" class="<?=isset($field) && $field=='total'?$sort:'';?>" href="#"><?=$lang['orders_lable_9']?></a></th>
            <th><a id="order_way" class="<?=isset($field) && $field=='order_way'?$sort:'';?>" href="#"><?=$lang['orders_lable_10']?></a></th>
            <th><a id="add_time" class="<?=isset($field) && $field=='add_time'?$sort:'';?>" href="#"><?=$lang['orders_lable_11']?></a></th>
            <th><a id="is_print" class="<?=isset($field) && $field=='is_print'?$sort:'';?>" href="#"><?=$lang['orders_lable_12']?></a></th>
            <th><a id="order_status_id" class="<?=isset($field) && $field=='order_status_id'?$sort:'';?>" href="#"><?=$lang['global_lable_16']?></a></th>
            <th><a id="order_status_i" class="" href="#"><?=$lang['orders_lable_13']?></a></th>
            <th style="text-align:center"><?=$lang['global_lable_21']?></th>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><input type="text" class="stext" name="invoice_no" value="<?=isset($invoice_no)?$invoice_no:''?>"></td>
            <td><input type="text" class="stext" name="nickname" lang="zh-TW" x-webkit-speech x-webkit-grammar="bUIltin:search" value="<?=isset($nickname)?$nickname:''?>"></td>
            <td><input type="text" class="stext" name="phone" lang="zh-TW" x-webkit-speech x-webkit-grammar="bUIltin:search" value="<?=isset($phone)?$phone:''?>"></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>
              <select name="order_status_id">
                <option value=""><?=$lang['orders_lable_38']?></option>
                <?php foreach($orderStatus as $key=>$lag):?>
                <option value="<?=$key?>" <?=isset($order_status_id) && $order_status_id==$key?'selected':''?> >--<?=$lag?>--</option>
                <?php endforeach;?>
              </select>
            </td>
            <td style="text-align:center"><input type="submit" class="btn btn-small btn-primary" name="sub_filter" value="<?=$lang['global_lable_31']?>"/></td>
          </tr>
        </thead>
        <tbody class="table">
          <?php $totle_fee=0;$totle_process=0;$totle_complete=0?>
          <?php if(isset($lists_count) && $lists_count>0):?>
          <?php $print_data=array('1'=>$lang['orders_lable_87'],'2'=>$lang['orders_lable_88'],'3'=>'缺纸卡纸','4'=>'過熱');?>
          <?php foreach($lists->result_array() as $list):
            $urls=site_url('admins/orders/%s/'.$list['id']);
            $totle_fee+=$list['total'];
            $totle_process+=$list['order_status_id']==2?$list['total']:0;
            $totle_complete+=$list['order_status_id']==3?$list['total']:0;
          ?>
          <?php if($list['order_status_id']==1) { $order_status=$lang['orders_lable_64'] ;} elseif($list['order_status_id']==2){ $order_status=$lang['orders_lable_65'] ;}
            elseif($list['order_status_id']==3) { $order_status=$lang['orders_lable_66'] ;} elseif($list['order_status_id']==4){ $order_status=$lang['orders_lable_67'] ;}
          ?>
          <?php if($list['order_status_id']==1) { $status_color='style="color:blue"' ;} elseif($list['order_status_id']==2){ $status_color='style="color:red"' ;}
            elseif($list['order_status_id']==3) { $status_color='style="color:green"' ;} elseif($list['order_status_id']==4){ $status_color='style="color:orange"' ;}
          ?>
          <tr>
            <td><input type="checkbox" class="chk_one"  value="<?=$list['id']?>"></td>
            <td class="a-center"><?=$list['invoice_no']?></td>
            <td title="<?=$list['nickname']?>"><?=mb_substr($list['nickname'],0,7,'utf-8')?>
              <?php if(mb_strlen($list['nickname'])>7) echo '...';?></td>
            <td><?=$list['phone']?></td>
            <td><?=$list['total']?></td>
            <td>
             <?php if($list['order_way']==1){echo $lang['orders_lable_68'];}else if($list['order_way']==2){echo $lang['orders_lable_69'];}else{echo $list['order_way'];}?>
            </td>
            <td><?=date($format_time,$list['add_time'])?></td>
            <td><?=$print_data[$list['is_print']]?></td>
            <?php if($list['order_status_id']==1):?>
            <td><a href="<?=site_url('admins/orders/integral/'.$list['id']).'?symbol=2'?>" <?=$status_color?>><?=$order_status?></a></td>
            <?php elseif($list['order_status_id']==2):?>
            <td><a href="<?=site_url('admins/orders/integral/'.$list['id']).'?symbol=3'?>" <?=$status_color?>><?=$order_status?></a></td>
            <?php elseif($list['order_status_id']==3):?>
            <td><a href="<?=site_url('admins/orders/integral/'.$list['id']).'?symbol=4'?>" <?=$status_color?>><?=$order_status?></a></td>
            <?php elseif($list['order_status_id']==4):?>
            <td><a href="<?=site_url('admins/orders/integral/'.$list['id']).'?symbol=1'?>" <?=$status_color?>><?=$order_status?></a></td>
            <?php endif;?>
            <td><?php echo $list['pay_status'] == 1 ? $lang['orders_lable_70'] : $lang['orders_lable_71'] ?></td>
            <td class="listaction">
              <a href="<?=sprintf($urls,"view")?>" class="l_browse"><?=$lang['global_lable_26']?></a>
              <a href="javascript:void(0);" onClick="delete_item('<?=sprintf($urls,"delete")?>');" class="l_delete"><?=$lang['global_lable_25']?></a>
            </td>
          </tr>
          <?php endforeach;?>
          <?php else:?>
          <tr>
            <td colspan="9" class="nodata"><p><?=$lang['global_lable_42']?></p></td>
          </tr>
          <?php endif;?>
        </tbody>
      </table>
      <p>
        <input type="button" class="btn btn-small" onclick="delete_allitem('<?=site_url('admins/orders/delete_batch')?>')" value="<?=$lang['global_lable_28']?>"/>
      </p>
      <p>
        <b style="color:red"><?=$lang['orders_lable_14']?>:</b>$<?php echo $total_year_fee;?> /
        <b><?=$lang['orders_lable_15']?>:</b>$<?php echo $totle_fee;?> /
        <b style="color:red"><?=$lang['orders_lable_16']?>:</b>$<?php echo $totle_process;?> /
        <b style="color:blue"><?=$lang['orders_lable_17']?>:</b>$<?php echo $totle_complete;?>
      </p>
      <!-- .tableactions ends -->
      <div id="pagination"><?php echo $pagination;?><div class="listscount"><?=$lang['global_lable_29']?> <?=$lists_count?> <?=$lang['global_lable_30']?></div></div>
      <!-- .pagination ends -->
    </form>
  </div>
  <!-- .block_content ends -->
  <div class="bendl"></div>
  <div class="bendr"></div>
</div>
<!-- .block ends -->
<script type="text/javascript" charset="utf-8">
function promotion_url(urls) {
  var delete_string="";
  $("input.chk_one").each(function(){
    if($(this).attr('checked')=='checked'){
      delete_string+=","+$(this).val()
    }
  });
  delete_string=delete_string.substring(1);
  if(delete_string!=""){
    urls=urls+'?promotion_string='+delete_string;
    location.href=urls;
  }else{
    alert('請先選擇短信推廣對象');
  }
}
</script>
<?php $this->load->view('common/admin_footer');?>
